public class MyQueue {
    static class ListNode{
        public int val;
        public ListNode next;

        public ListNode(int val) {
            this.val = val;
        }
    }
    public ListNode head;
    public ListNode last;

    public int usedSize;

    public void offer(int val){
        ListNode node = new ListNode(val);
        if (head == null ){
            head = node;
            last = node;
        }else {
            last.next = node;
            last = last.next;
        }
        usedSize++;
    }

    public int getUsedSize(){
        return usedSize;
    }

    public int poll(){
        if (head == null){
            return -1;
        }int val = -1;
         if (head.next == null){
             val = head.val;
             head = null;
             last = null;
             return val;
        }
         val = head.val;
         head = head.next;
         usedSize--;
         return val;
    }

    public int peak(){
        if (head == null){
            return -1;
        }int val = -1;
        return head.val;
    }
}
